package org.goldonframework.website.system.domain;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class testHibernate {
	private static SessionFactory sessionFactory;

	@BeforeClass
	public static void beforeClass() {
		sessionFactory = new Configuration().configure().buildSessionFactory();
	}

	@AfterClass
	public static void afterClass() {
		if (sessionFactory != null) {
			sessionFactory.close();
		}
	}

	public UserInfo getUserInfo() {
		UserInfo info = new UserInfo();
		info.setRemark("wyang");
		info.setUserName("yangwu");
		info.setPassword("uuid");
		info.setBirthday(new Date());
		return info;
	}

	@Test
	public void testAddUserInfo() {
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		session.save(getUserInfo());
		session.getTransaction().commit();
		session.close();
	}

}
